package com.zkzx.wlhy.adaptor.controller.driver;

import com.zkzx.common.driver.command.DriverCommand;
import com.zkzx.common.driver.param.DriverInvitationParam;
import com.zkzx.common.driver.param.DriverThreeElementsParam;
import com.zkzx.common.driver.model.DriverVO;
import com.zkzx.wlhy.adaptor.service.driver.DriverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 北京中科智兴物联科技有限公司 @版权所有
 *
 * @Author: zhaoyihe@zkraising.com
 * @Date: 2021/05/20/13:28
 * @Description:
 */
@RestController
@Validated
@Api( tags="司机接口")
@RequestMapping(value = "/drivers")
public class DriverController {

    @Autowired
    private DriverService driverService;


    @GetMapping("/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "查询是否存在该司机", notes = "查询是否存在该司机")
    public DriverCommand getDriver(@PathVariable("id")Integer id,@RequestParam("name") String name,@RequestParam("code") String  idCard){
      return   driverService.getDriver(id,name,idCard);
    }


    @PostMapping("/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "上传司机信息", notes = "上传司机信息")
    public DriverCommand add(@PathVariable("id") Integer id, @RequestBody @Valid DriverVO driverVO,@RequestParam("captcha") String  captcha,@RequestParam("identityKey") String  identityKey) {
        return driverService.add(id,driverVO,captcha,identityKey);
    }

    @GetMapping("/{id}/status")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "查询添加司机审核状态", notes = "查询添加司机审核状态")
    public DriverCommand  getStatus(@PathVariable("id")Integer id,@RequestParam("three_id") String  threeId){

        return driverService.getStatus(id,threeId);
    }



    @PostMapping("/{id}/three_elements")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "司机手机号三要素验证码获取", notes = "司机手机号三要素验证码获取")
    public DriverCommand getIdentityKey(@PathVariable("id")Integer id,@RequestBody @Valid DriverThreeElementsParam driverThreeElementsParam) {

        return driverService.getIdentityKey(id, driverThreeElementsParam);
    }

    @PostMapping("/{id}/contract_sign")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "邀请司机签约", notes = "邀请司机签约")
    public DriverCommand getContractSign(@PathVariable("id")Integer id,@RequestBody @Valid DriverInvitationParam driverInvitationParam) {
       return driverService.getContractSign( id, driverInvitationParam);
    }

    @GetMapping("/{id}/contract_status")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "查询合同签署情况", notes = "查询合同签署情况")
    public DriverCommand getContractStatus(@PathVariable("id")Integer id,@RequestParam("contract_num")String contractNum,@RequestParam("mobile") String  mobile){

        return driverService.getContractStatus(id, contractNum,mobile);
    }

}
